#include<iostream>
#include<string.h>
using namespace std;
int mx[1005][1005];
int n,k;
int ans;
int vis[1005];

void dfs(int l,int step){
    if(step == k){
        ans++;
        return ;
    }
    for(int i = l;i <= n;i++){
        for(int j = 1;j <= n;j++){
            //找到可以放的，并且没被占据
            if(mx[i][j] == 1 && vis[j] == 0){
                vis[j] = 1;
                dfs(i + 1,step + 1);
                vis[j] = 0;
            }
        }
    }
}
int main(){
    
    while(cin >> n >> k){
        ans = 0;
        memset(vis,0,sizeof(vis));
        if(n == -1 && k == -1) break;
        
        for(int i = 1;i <= n;i++){
            for(int j = 1;j <= n;j++){
                char c;
                cin >> c;
                if(c == '.') mx[i][j] = 0;
                else mx[i][j] = 1;
            }
        }
        dfs(0,0);
        cout << ans << "\n";
    }
} 